package com.netease.image.video;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import com.netease.g.b;

public abstract class ImageViewTouchBase extends ImageView
{
  private static final String a = "ImageViewTouchBase";
  static final float n = 1.25F;
  private final Matrix b = new Matrix();
  private final float[] c = new float[9];
  private v d;
  private an e;
  protected Matrix f = new Matrix();
  protected Matrix g = new Matrix();
  protected aj h = new aj(null);
  int i = -1;
  int j = -1;
  public float k;
  protected Handler l = new Handler();
  boolean m = true;
  private Runnable o = null;

  public ImageViewTouchBase(Context paramContext)
  {
    super(paramContext);
    h();
  }

  public ImageViewTouchBase(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    h();
  }

  private void a(Bitmap paramBitmap, int paramInt)
  {
    super.setImageBitmap(paramBitmap);
    Drawable localDrawable = getDrawable();
    if (localDrawable != null)
      localDrawable.setDither(true);
    Bitmap localBitmap = this.h.b();
    this.h.a(paramBitmap);
    this.h.a(paramInt);
    if ((localBitmap != null) && (localBitmap != paramBitmap) && (this.e != null))
      this.e.a(localBitmap);
  }

  private void a(aj paramaj, Matrix paramMatrix, boolean paramBoolean)
  {
    float f1 = getWidth();
    float f2 = getHeight();
    float f3 = paramaj.f();
    float f4 = paramaj.e();
    paramMatrix.reset();
    float f5 = Math.min(f1 / f3, 3.0F);
    float f6 = Math.min(f2 / f4, 3.0F);
    float f7;
    if (paramBoolean)
      f7 = Math.max(f5, f6);
    while (true)
    {
      paramMatrix.postConcat(paramaj.c());
      paramMatrix.postScale(f7, f7);
      paramMatrix.postTranslate((f1 - f3 * f7) / 2.0F, (f2 - f7 * f4) / 2.0F);
      return;
      f7 = Math.min(f5, f6);
    }
  }

  private void h()
  {
    setScaleType(ImageView.ScaleType.MATRIX);
  }

  protected float a(Matrix paramMatrix)
  {
    return a(paramMatrix, 0);
  }

  protected float a(Matrix paramMatrix, int paramInt)
  {
    paramMatrix.getValues(this.c);
    return this.c[paramInt];
  }

  public void a()
  {
    a(null, true, false);
  }

  public void a(float paramFloat)
  {
    a(paramFloat, getWidth() / 2.0F, getHeight() / 2.0F);
  }

  protected void a(float paramFloat1, float paramFloat2)
  {
    this.g.postTranslate(paramFloat1, paramFloat2);
  }

  protected void a(float paramFloat1, float paramFloat2, float paramFloat3)
  {
    if (paramFloat1 > this.k)
      paramFloat1 = this.k;
    float f1 = paramFloat1 / d();
    this.g.postScale(f1, f1, paramFloat2, paramFloat3);
    setImageMatrix(e());
    a(true, true);
  }

  protected void a(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
  {
    float f1 = (paramFloat1 - d()) / paramFloat4;
    float f2 = d();
    long l1 = System.currentTimeMillis();
    this.l.post(new o(this, paramFloat4, l1, f2, f1, paramFloat2, paramFloat3));
  }

  public void a(Bitmap paramBitmap, boolean paramBoolean1, boolean paramBoolean2)
  {
    a(new aj(paramBitmap), paramBoolean1, paramBoolean2);
  }

  public void a(aj paramaj, boolean paramBoolean1, boolean paramBoolean2)
  {
    int i1 = getWidth();
    this.m = paramBoolean2;
    if (i1 <= 0)
    {
      this.o = new p(this, paramaj, paramBoolean1, paramBoolean2);
      return;
    }
    if (paramaj.b() != null)
    {
      a(paramaj, this.f, paramBoolean2);
      a(paramaj.b(), paramaj.a());
    }
    while (true)
    {
      b.c("setImageRotateBitmapResetBase", "mDisplaybitmap==: " + this.h.b());
      if (paramBoolean1)
        this.g.reset();
      setImageMatrix(e());
      this.k = f();
      break;
      this.f.reset();
      setImageBitmap(null);
    }
  }

  public void a(an paraman)
  {
    this.e = paraman;
  }

  public void a(v paramv)
  {
    this.d = paramv;
  }

  protected void a(boolean paramBoolean1, boolean paramBoolean2)
  {
    float f1 = 0.0F;
    if (this.h.b() == null)
      return;
    Matrix localMatrix = e();
    RectF localRectF = new RectF(0.0F, 0.0F, this.h.b().getWidth(), this.h.b().getHeight());
    localMatrix.mapRect(localRectF);
    float f2 = localRectF.height();
    float f3 = localRectF.width();
    int i2;
    float f4;
    if (paramBoolean2)
    {
      i2 = getHeight();
      if (f2 < i2)
        f4 = (i2 - f2) / 2.0F - localRectF.top;
    }
    while (true)
    {
      label109: int i1;
      if (paramBoolean1)
      {
        i1 = getWidth();
        if (f3 >= i1)
          break label210;
        f1 = (i1 - f3) / 2.0F - localRectF.left;
      }
      while (true)
      {
        a(f1, f4);
        setImageMatrix(e());
        break;
        if (localRectF.top > 0.0F)
        {
          f4 = -localRectF.top;
          break label109;
        }
        if (localRectF.bottom >= i2)
          break label255;
        f4 = getHeight() - localRectF.bottom;
        break label109;
        label210: if (localRectF.left > 0.0F)
        {
          f1 = -localRectF.left;
          continue;
        }
        if (localRectF.right >= i1)
          continue;
        f1 = i1 - localRectF.right;
      }
      label255: f4 = 0.0F;
    }
  }

  public void b()
  {
    b(1.25F);
  }

  protected void b(float paramFloat)
  {
    if (d() >= this.k);
    while (true)
    {
      return;
      if (this.h.b() != null)
      {
        float f1 = getWidth() / 2.0F;
        float f2 = getHeight() / 2.0F;
        this.g.postScale(paramFloat, paramFloat, f1, f2);
        setImageMatrix(e());
        continue;
      }
    }
  }

  protected void b(float paramFloat1, float paramFloat2)
  {
    a(paramFloat1, paramFloat2);
    setImageMatrix(e());
  }

  public void b(float paramFloat1, float paramFloat2, float paramFloat3)
  {
    if (paramFloat1 > this.k)
      paramFloat1 = this.k;
    float f1 = d();
    float f2 = paramFloat1 / f1;
    if (paramFloat1 < 1.0F)
      f2 = 1.0F / f1;
    this.g.postScale(f2, f2, paramFloat2, paramFloat3);
    setImageMatrix(e());
    a(true, true);
  }

  protected void b(Matrix paramMatrix)
  {
    this.g.postConcat(paramMatrix);
    setImageMatrix(e());
    a(true, true);
  }

  public void c()
  {
    c(1.25F);
  }

  public void c(float paramFloat)
  {
    if (this.h.b() == null)
      return;
    float f1 = getWidth() / 2.0F;
    float f2 = getHeight() / 2.0F;
    Matrix localMatrix = new Matrix(this.g);
    localMatrix.postScale(1.0F / paramFloat, 1.0F / paramFloat, f1, f2);
    if (a(localMatrix) < 1.0F)
      this.g.setScale(1.0F, 1.0F, f1, f2);
    while (true)
    {
      setImageMatrix(e());
      a(true, true);
      break;
      this.g.postScale(1.0F / paramFloat, 1.0F / paramFloat, f1, f2);
    }
  }

  public void c(float paramFloat1, float paramFloat2, float paramFloat3)
  {
    float f1 = getWidth() / 2.0F;
    float f2 = getHeight() / 2.0F;
    b(f1 - paramFloat2, f2 - paramFloat3);
    a(paramFloat1, f1, f2);
  }

  public float d()
  {
    return a(this.g);
  }

  public Matrix e()
  {
    this.b.set(this.f);
    this.b.postConcat(this.g);
    return this.b;
  }

  public float f()
  {
    float f1;
    if (this.h.b() == null)
      f1 = 1.0F;
    while (true)
    {
      return f1;
      f1 = 4.0F * Math.max(this.h.f() / this.i, this.h.e() / this.j);
    }
  }

  public Bitmap g()
  {
    if (this.h != null);
    for (Bitmap localBitmap = this.h.b(); ; localBitmap = null)
      return localBitmap;
  }

  protected void onDetachedFromWindow()
  {
    super.onDetachedFromWindow();
    try
    {
      if (this.h != null)
        this.h.g();
      return;
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
    this.i = (paramInt3 - paramInt1);
    this.j = (paramInt4 - paramInt2);
    Runnable localRunnable = this.o;
    if (localRunnable != null)
    {
      this.o = null;
      localRunnable.run();
    }
    if (this.h.b() != null)
    {
      a(this.h, this.f, this.m);
      setImageMatrix(e());
    }
    if (this.d != null)
      this.d.a();
  }

  public void setImageBitmap(Bitmap paramBitmap)
  {
    a(paramBitmap, 0);
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.image.video.ImageViewTouchBase
 * JD-Core Version:    0.6.0
 */